//***********************************************************************
//	File:		SpiderMine.cpp
//	Author:		
//	Course:		SGP 1405
//	Purpose:	
//***********************************************************************
//***********************************************************************
//	Purposfully left blank for all comments regarding this file 
//	
//	
//	
//***********************************************************************



#include "SpiderMine.h"

SpiderMine::SpiderMine(float posX, float posY)
{
	SetAcceleration({ 0 , 0 }); 
	SetActive(false); 
	SetAttackRange(3);
	SetConfuseCDL(0); 
	SetConfuseTimer(0); 
	SetDestructionTimer(4); 
	SetDestructionTimerLength(4); 
	SetDynamicFrictionCoefficient(.2f); 
	SetHealth(40); 
	//SetImage();
	SetKnockbackCDL(1); 
	SetKnockBackTimer(0); 
	SetMass(2); 
	SetMaxHealth(40); 
	SetMaxSpeed(100); 
	SetPassable(false);
	SetPosition(SGD::Point{ posX, posY }); 
	SetRootCDL(5); 
	SetRootTimer(0); 
	SetRotation(0);
	SetSize(SGD::Size{ 16, 16 }); 
	SetSpeed(0); 
	SetStaticFrictionCoefficient(.4f);
	//SetTakeDamage() particle emitter
	SetTarget(nullptr); 
	SetValue(ENT_SPIDERMINE);
	SetVelocity(SGD::Vector{ 0, -1 }); 



}

//Interface
void SpiderMine::Update(float dt)
{

	if (mTarget->GetPosition().x - this->GetPosition().x < 300 || mTarget->GetPosition().y - this->GetPosition().y < 300)
	{
		m_bActive = true;

	}

	if (m_bActive == true)
	{
		this->Move();
		m_fDestructionTimer++;
	}


	if (mTarget->GetPosition().x - this->GetPosition().x < 5 || mTarget->GetPosition().y - this->GetPosition().y < 5)
		this->Attack(dt);

	if (m_fDestructionTimer >= m_fDestructionTimerLength)
		m_fDestructionTimer++;

	//Last line of function 
	Entity::Update(dt); 
}

void SpiderMine::Render()
{

}

void SpiderMine::HandleCollision(const IEntity* pOther)
{

}

void SpiderMine::HandleEvent()
{

}

SGD::Rectangle SpiderMine::GetRect() const
{
	return SGD::Rectangle{}; 
}

void SpiderMine::ModifyHealth(float hpAmount)
{

	mTarget->ModifyHealth(-40);

}

void SpiderMine::ApplyFriction(float dt)
{

}

void SpiderMine::Attack(float dt)
{



}

void SpiderMine::Move(void)
{

	if (mTarget->GetPosition().x > this->GetPosition().x)
		this->m_ptPosition.x++;
	else
		this->m_ptPosition.x--;

	if (mTarget->GetPosition().y > this->GetPosition().y)
		this->m_ptPosition.y++;
	else
		this->m_ptPosition.y--;

}